package com.atguigu.gmall.juc.juc;

/**
 * @author 陈昆昆
 * @version 1.0
 * @date 2020/5/28 16:29
 */
public class SingeleTenTest {
    private SingeleTenTest (){
        System.out.println(Thread.currentThread().getName()+"我实例化了一次");
    }
    private static volatile SingeleTenTest singeleTenTest = null;

    public static SingeleTenTest getincetace(){
        if (singeleTenTest ==null){
            synchronized (SingeleTenTest.class) {
                if (singeleTenTest==null) {
                    singeleTenTest = new SingeleTenTest();
                }
            }
        }
        return singeleTenTest;
    }

    public static void main(String[] args) {
        for (int i = 0; i <100 ; i++) {
            new Thread(()->{
                SingeleTenTest.getincetace();
            },String.valueOf(i)).start();
        }
    }
}
